// pages/dish/myorder/myorder.js
const app = getApp();
const server = require('../../../utils/server');

Page({

  /**
   * 页面的初始数据
   */
  data: {
    currentIndex: 0,
    orderList:[]
  },

  goDeliver(e){
    let item=e.currentTarget.dataset.item;
    console.log(item)
    wx.navigateTo({
      url: '/pages/dish/deliver/deliver',
    })
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    console.log("werwerwerwerwerwerwer", wx.getStorageSync('myorder-page-type'));
    switch (wx.getStorageSync('myorder-page-type')) {
      case "notpay": 
        this.setData({
          currentIndex: 1
        });
        break;
      case "notsend": 
        this.setData({
          currentIndex: 2
        });
        break;
      case "notget": 
        this.setData({
          currentIndex: 3
        });
        break;
      case "comment": 
        this.setData({
          currentIndex: 4
        });
        break;
      case "afterSale": 
        this.setData({
          currentIndex: 5
        });
        break;
    }
    let that=this;
    server.requestForm(true,'get','order',{},function(res){
      if(res.code == 0){
        that.setData({
          orderList:res.data
        })
      }else{
        console.log(res)
      }
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    let tabbar=this.selectComponent("#tabbar");
    tabbar.setData({
      selected:3
    })
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  },

  switchTab(e) {
    this.setData({
      currentIndex: e.currentTarget.dataset.counter
    });
  }
})